<?php
namespace App\Model;
use PhalApi\Model\DataModel;

class MirCategory extends DataModel {

    protected function getTableName($id) {
        return 'game_category';
    }

    //插入数据
    public function selectByWhere($json) {
        $where = array();
        $where['Category'] = $json['Category'];
        $where['CategoryTitle'] = $json['CategoryTitle'];

        $list = $this->getORM()->where( $where )
            ->fetchOne();
        return $list ? $list : $this->insertMir($where);
    }

    //插入数据
    public function insertMir($data) {
        $data['update_time'] = date("Y-m-d H:i:s",time());
        $data['create_time'] = date("Y-m-d H:i:s",time());
        return $this->getORM()->insert($data);
    }


}
